package com.example.backend.service;

import com.example.backend.utils.Response;
import com.example.backend.utils.ResponseStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

@Service
public class ImageUploadService {
    Path path = Paths.get("uploads");

    public Integer save(MultipartFile multipartFile) {
        try {
            Files.copy(multipartFile.getInputStream(), path.resolve(multipartFile.getOriginalFilename()));
            return 0;
        } catch (IOException exception) {
            return -1;
        }

    }
}
